<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改栏目')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-channel-edit" th:object="${channel}">
			<input id="channelId" name="id" type="hidden" th:field="*{id}" />
			<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
			<div class="form-group">
				<label class="col-sm-3 control-label ">上级栏目：</label>
				<div class="col-sm-8">
				    <div class="input-group">
						<input class="form-control" type="text" id="treeName" onclick="selectChannelTree()" readonly="readonly" th:value="${parent.channelName}">
					    <span class="input-group-addon"><i class="fa fa-search"></i></span>
				    </div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="channelName" th:field="*{channelName}" id="channelName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目状态：</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getDict('sys_data_status')}">
						<input type="radio" th:id="${dict.id}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
						<label th:for="${dict.id}" th:text="${dict.dictName}"></label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="number" name="orderNum" th:field="*{orderNum}" required="required">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea name="remark" maxlength="500" class="form-control" rows="3" th:field="*{remark}"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "cms/channel";
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-channel-edit').serialize(), function(){
	        		$(window.parent.document).find('#btnRefresh').click();
	        	});
	        }
	    }
	
		/*栏目管理-修改-选择栏目树*/
		function selectChannelTree() {
			var parentId = $("#treeId").val();
			if(parentId != "root") {
			    var options = {
					title: '栏目选择',
					width: "380",
					url: prefix + "/selectChannelTree/" + parentId,
					callBack: function (index, layero){
			   			var body = layer.getChildFrame('body', index);
			   			$("#treeId").val(body.find('#treeId').val());
			   			$("#treeName").val(body.find('#treeName').val());
			   			layer.close(index);
					}
				};
				$.modal.openOptions(options);
			}
		}
		
	</script>
</body>
</html>
